package exception;

/**
 * throw关键字,用于主动向方法外抛出一个异常
 *
 *
 */
public class ThrowDemo {
    public static void main(String[] args) throws IllegalAgeException {
        Person p = new Person();
//        p.setAge(22);
        try {
            p.setAge(1000);//满足语法,但不满足业务
        } catch (IllegalAgeException e) {
//            System.out.println("出错了");
            e.printStackTrace();
        }

        System.out.println("此人年龄:"+p.getAge());
    }
}
